<template>
  <div>

    <Panel title="短信模板管理" useBack>
         <ModifyForm
        slot="body"
        :editColumn="editColumn"
        :temporaryData='temporaryData'
        labelWidth="150px"
        :updateData="updateData"
      >
        <p
          slot="title"
        ></p>
      </ModifyForm>
    </Panel>
  </div>
</template>
<script>
import Panel from "@/components/Panel";
import ModifyForm from "@/components/ModifyForm";
import ModalPanel from "@/components/ModalPanel";
import FileUpload from '@/components/FileUpload';
import request from "@/tools/request";


export default {
  name:'smsTemplateInfo',
  components: {
    FileUpload,
    Panel,
    ModalPanel,
    ModifyForm
  },
  data() {
    return {
     configValue:"",
      editorOption: {},
      typeList: [],
      temporaryData: {
        coverImg: [],
        publishStatus: false
      },
      editColumn: [
        {
          name: "名称",
          prop: "name",
          type: "text",
          width:12,
          required: true
        },
        {
          name: "模板编号",
          width: 12,
          prop: "mark",
          type: "text",
          required: true
        },
        {
          name: "签名",
          width: 12,
          prop: "mark",
          type: "text",
          required: true
        },
        {
          name: "模板内容",
          width: 24,
          prop: "mark",
          type: "text",
          required: true
        },
      ],
    };
  },
  computed: {
 

  },
  methods: {
   async updateData(values) {
     const { name, mark, state, id } = values
     let url, msg
     if(id){
        url = '/grate/group/update'
        msg = '编辑成功'
     }else{
        url = '/grate/group/add'
        msg = '添加成功'
     }
      let res = await request({
        url: url,
        method: "POST",
        data: { name, mark, state, id }
      });
      if(res.code !==0 ) return
      this.$message.success(msg)
      this.$router.go(-1)
    },
    async fetchData(id){
      let { rateGroup } = await request({
        url: "/grate/group/info/"+id,
        method: "GET",
        data: {}
      });
      // console.log('数据',rateGroup)
      this.temporaryData = rateGroup
    }
  },
  created() {
    if(this.$route.query.id)
      this.fetchData(this.$route.query.id)
  }
};
</script>

<style lang='scss' module>

</style>